﻿using Blog190311.Models.DBModel;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;

namespace Blog190311.Models.DAL
{
    public class UserService
    {
        public static List<UIData> GetArticleAbout()//关于我
        {
            List<UIData> list = new List<UIData>();
            string sql = "select SelfSlogo,SelfPhoto from [dbo].[User]";
            SqlDataReader dr = DBHelper.ExecuteReader(sql);
            while (dr.Read())
            {
                list.Add(new UIData
                {
                    Title = dr["SelfSlogo"].ToString(),
                    PicUrl = dr["SelfPhoto"].ToString()
                });
            }
            return list;
        }

        public User GetUserInfo(string userName)
        {
            User user = null;
            string sql = string.Format("select * from [dbo].[User] where UserName='{0}'", userName);
            SqlDataReader dr = DBHelper.ExecuteReader(sql);
            if (dr.Read())
            {
                user = new User()
                {
                    UserName = dr["UserName"].ToString(),
                    Password = dr["Password"].ToString(),
                    SelfSlogo = dr["SelfSlogo"].ToString(),
                    SelfPhoto = dr["SelfPhoto"].ToString(),
                    LastLoginTime = dr["LastLoginTime"].ToString(),
                    AboutMe = dr["AboutMe"].ToString()
                };
            }
            return user;
        }
    }
}